package com.twu.biblioteca.command;

import com.twu.biblioteca.db.BookStore;
import com.twu.biblioteca.model.User;
import com.twu.biblioteca.utilities.ConsoleReader;

public class WhoCheckedOutBookCommand implements Command {
    private BookStore bookStore;
    private ConsoleReader reader;

    public WhoCheckedOutBookCommand(BookStore bookStore, ConsoleReader reader) {
        this.bookStore = bookStore;
        this.reader = reader;
    }

    @Override
    public void execute() {
        User user = bookStore.getUserCheckedOutABook(reader.readIdFromConsole("Book"));
        if(user == null)
            System.out.println("No user checked out the mentioned book");
        else
            user.printUserInfo();
    }
}
